package com.feisuanyz.controller;

import com.feisuanyz.dto.LogoQuery;
import com.feisuanyz.dto.RestResult;
import com.feisuanyz.service.LogoService;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/logos")
@Slf4j
public class LogoController {

    @Autowired
    private LogoService logoService;

    @PostMapping("/create")
    public ResponseEntity<RestResult<Void>> createLogo(@Valid @RequestBody LogoQuery logoQuery) {
        RestResult<Void> result = logoService.createLogo(logoQuery);
        return ResponseEntity.ok(result);
    }

    @PutMapping("/edit")
    public ResponseEntity<RestResult<Void>> editLogo(@Valid @RequestBody LogoQuery logoQuery) {
        RestResult<Void> result = logoService.editLogo(logoQuery);
        return ResponseEntity.ok(result);
    }

    @DeleteMapping("/delete/{logoId}")
    public ResponseEntity<RestResult<Void>> deleteLogo(@PathVariable Integer logoId, @RequestParam Integer deleteBy) {
        RestResult<Void> result = logoService.deleteLogo(logoId, deleteBy);
        return ResponseEntity.ok(result);
    }
}